package com.pansoft.openplanet.bean;

import com.pansoft.openplanet.constant.IPAssetsConstant;

import java.io.Serializable;

/**
 * 本地钱包账户
 * Created by YQS on 2018/3/27.
 */

public class Account implements Serializable {
    //todo  历史原因，服务器accounttype比本地多1 ！！
    //普通钱包
    public static final int ACCOUNT_TYPE_COMMON = 0;
    //观察钱包
    public static final int ACCOUNT_TYPE_OBSERVE = 1;
    //冷钱包
    public static final int ACCOUNT_TYPE_COLD = 2;
    //多重签名钱包
    public static final int ACCOUNT_TYPE_MULTI_SIGN = 3;

    //账户地址
    private String address;
    //账户名称
    private String acccountName;
    //账户头像
    private String accountAvatar;
    //kestore名称（完整文件路径）
    private String fileName;
    //imuserid
    private String imUserId;
    //创建时间
    private String createTime;
    //是否是主账号
    private boolean isMaster;

    //公钥
    private String publicKey;
    //加密的私钥
    private String secretPrivateKey;

    //eos active 公钥
    private String eosActivePubKey;
    //eos active 加密私钥
    private String eosActivePriKey;
    //主账户地址
    private String mainAccoutAddress;
    //块名称 Ethereum 默认
    private String blockChainName = IPAssetsConstant.ChainEnum.ETH.chainName;
    //账户类型  0 普通账户 1 观察者账户（只能查看余额，不能进行转账操作） 2冷钱包，本地不存储私钥
    private int accountType;

    //是否是当前显示的账户（eth btc 界面）
    private boolean isCurrentShow;

    //当前账户是否可用（新创建的账户如果没有走完备份助记词的页面，那么账户不可用）
    private boolean isEnable;

    //是否已经激活 （eos）
    private boolean isActivate;
    private String eosTempName;
    private String eosAccountNames;//eos所有账户名
    private String coldWalletCardUid;//冷钱包所在的卡片的uid

    /** btc hd bip49钱包 **/
    //HD btc钱包的xpub
    private String hdBtcXpub;
    //表示HD btc钱包的选中子地址
    private String hdBtcCurrentChildAddress;
    //表示HD btc钱包的选中子地址的路径最大index，意思是
    //将要生成这么多个子地址，如"6"表示path"/0/1"....."/0/6"的地址都生成出来
    private String hdBtcMaxChildIndex;
    //是否是hd钱包，hd支持下新创建或单个导入的btc都是hd
    private boolean isHdWallet;

    /**
     * 加密的助记词
     */
    private String secretMnemonic;

//    public enum BlockChainEnum {
//        ETH("ETH"),
//        BTC("BTC"),
//        EOS("EOS"),
//        TURBOCHAIN("TURBOCHAIN"),
//        EOSTEST("EOSTEST"),
//        ACHAIN("ACT"),
//        BCH("BCH"),
//        ETE("ETE");
//
//        private String fullName;
//
//        BlockChainEnum(String fullName) {
//            this.fullName = fullName;
//        }
//
//        public String chainName {
//            return fullName;
//        }
//
//        public static BlockChainEnum getByChainName(String chainName) {
//            for (BlockChainEnum item : BlockChainEnum.values()) {
//                if (item.fullName.equals(chainName)) {
//                    return item;
//                }
//            }
//            return null;
//        }
//    }

    public Account(String address, String acccountName, String accountAvatar) {
        this.address = address;
        this.acccountName = acccountName;
        this.accountAvatar = accountAvatar;
    }

    public Account() {

    }

    public boolean isEnable() {
        return isEnable;
    }

    public Account setEnable(boolean enable) {
        isEnable = enable;
        return this;
    }

    public String getPublicKey() {
        return publicKey;
    }

    public Account setPublicKey(String publicKey) {
        this.publicKey = publicKey;
        return this;
    }

    public String getSecretPrivateKey() {
        return secretPrivateKey;
    }

    public Account setSecretPrivateKey(String secretPrivateKey) {
        this.secretPrivateKey = secretPrivateKey;
        return this;
    }

    public String getMainAccoutAddress() {
        return mainAccoutAddress;
    }

    public Account setMainAccoutAddress(String mainAccoutAddress) {
        this.mainAccoutAddress = mainAccoutAddress;
        return this;
    }

    public String getBlockChainName() {
        return blockChainName;
    }

    public Account setBlockChainName(String blockChainName) {
        this.blockChainName = blockChainName;
        return this;
    }

    public int getAccountType() {
        return accountType;
    }

    public Account setAccountType(int accountType) {
        this.accountType = accountType;
        return this;
    }

    public boolean isCurrentShow() {
        return isCurrentShow;
    }

    public Account setCurrentShow(boolean currentShow) {
        isCurrentShow = currentShow;
        return this;
    }

    public boolean isMaster() {
        return isMaster;
    }

    public Account setMaster(boolean master) {
        isMaster = master;
        return this;
    }

    public String getFileName() {
        return fileName;
    }

    public Account setFileName(String fileName) {
        this.fileName = fileName;
        return this;
    }

    public String getAddress() {
        return address;
    }

    /**
     * 获取简略名称
     *
     * @return
     */
    public String getSimpleAddress() {
        if (address != null && address.length() > 20) {
            String address1 = address.replace(address.substring(6, address.length() - 4), "****");
            return address1;
        }
        return address;
    }

    public Account setAddress(String address) {
        this.address = address;
        return this;
    }

    public String getAcccountName() {
        return acccountName;
    }

    public Account setAcccountName(String acccountName) {
        this.acccountName = acccountName;
        return this;
    }

    public String getAccountAvatar() {
        return accountAvatar;
    }

    public Account setAccountAvatar(String accountAvatar) {
        this.accountAvatar = accountAvatar;
        return this;
    }

    public String getCreateTime() {
        return createTime;
    }

    public Account setCreateTime(String createTime) {
        this.createTime = createTime;
        return this;
    }

    public String getImUserId() {
        return imUserId;
    }

    public Account setImUserId(String imUserId) {
        this.imUserId = imUserId;
        return this;
    }

    public String getSecretMnemonic() {
        return secretMnemonic;
    }

    public Account setSecretMnemonic(String secretMnemonic) {
        this.secretMnemonic = secretMnemonic;
        return this;
    }

    public String getEosActivePubKey() {
        return eosActivePubKey;
    }

    public Account setEosActivePubKey(String eosActivePubKey) {
        this.eosActivePubKey = eosActivePubKey;
        return this;
    }

    public String getEosActivePriKey() {
        return eosActivePriKey;
    }

    public Account setEosActivePriKey(String eosActivePriKey) {
        this.eosActivePriKey = eosActivePriKey;
        return this;
    }

    public boolean isActivate() {
        return isActivate;
    }

    public Account setActivate(boolean activate) {
        isActivate = activate;
        return this;
    }

    public String getEosTempName() {
        return eosTempName;
    }

    public Account setEosTempName(String eosTempName) {
        this.eosTempName = eosTempName;
        return this;
    }

    public String getEosAccountNames() {
        return eosAccountNames;
    }

    public void setEosAccountNames(String eosAccountNames) {
        this.eosAccountNames = eosAccountNames;
    }

    public String getColdWalletCardUid() {
        return coldWalletCardUid;
    }

    public void setColdWalletCardUid(String coldWalletCardUid) {
        this.coldWalletCardUid = coldWalletCardUid;
    }

    public String getHdBtcXpub() {
        return hdBtcXpub;
    }

    public void setHdBtcXpub(String hdBtcXpub) {
        this.hdBtcXpub = hdBtcXpub;
    }

    public String getHdBtcCurrentChildAddress() {
        return hdBtcCurrentChildAddress;
    }

    public void setHdBtcCurrentChildAddress(String hdBtcCurrentChildAddress) {
        this.hdBtcCurrentChildAddress = hdBtcCurrentChildAddress;
    }

    public String getHdBtcMaxChildIndex() {
        return hdBtcMaxChildIndex;
    }

    public void setHdBtcMaxChildIndex(String hdBtcMaxChildIndex) {
        this.hdBtcMaxChildIndex = hdBtcMaxChildIndex;
    }

    public boolean isHdWallet() {
        return isHdWallet;
    }

    public void setHdWallet(boolean hdWallet) {
        isHdWallet = hdWallet;
    }
}

